package com.atguigu.jxc.controller;


import com.atguigu.jxc.domain.ErrorCode;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.service.DamageListGoodsService;
import com.atguigu.jxc.service.OverflowListGoodsService;
import com.atguigu.jxc.service.OverflowListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

//商品报溢
@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {


    @Autowired
    private OverflowListGoodsService overflowListGoodsService;

    @Autowired
    private OverflowListService overflowListService;
    //http://localhost:8080/overflowListGoods/save?overflowNumber=BY1605767033015
    //新增报溢单
    @PostMapping("/save")
    public ServiceVO save(OverflowList overflowList, String overflowListGoodsStr, HttpSession session){
        try {
            overflowListGoodsService.save(overflowList,overflowListGoodsStr,session);
            return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new ServiceVO(ErrorCode.PARA_TYPE_ERROR_CODE, ErrorCode.PARA_TYPE_ERROR_MESS);
        }
    }

    //http://localhost:8080/overflowListGoods/list
    //报溢单查询
    @PostMapping("/list")
    public Map<String,Object> list(String  sTime, String  eTime){
        return overflowListService.list(sTime,eTime);
    }


    //http://localhost:8080/overflowListGoods/goodsList
    //报溢单商品信息 Integer overflowListId
    @PostMapping("goodsList")
    public Map<String,Object> goodsList(Integer overflowListId){
        return overflowListGoodsService.goodsList(overflowListId);
    }
}
